package systeminfo

import (
	"fmt"
	"syscall"
)

func DiskUsage(path string) (disk Hdd) {
	fs := syscall.Statfs_t{}
	err := syscall.Statfs(path, &fs)
	if err != nil {
		return
	}
	disk.Path = path
	diskall := fs.Blocks * uint64(fs.Bsize) / 1024 / 1024 / 1024
	diskfree := fs.Bfree * uint64(fs.Bsize) / 1024 / 1024 / 1024
	disk.All = fmt.Sprint(diskall)
	disk.Free = fmt.Sprint(diskfree)
	disk.Used = fmt.Sprint(diskall - diskfree)
	return
}

func GetHDDStatus() (status []Hdd) {
	status = []Hdd{DiskUsage("/"), DiskUsage("/home")}
	return
}
